#!/usr/bin/env python
#coding=utf-8
#
'''
使用北网账号发送短信完整代码
前提安装阿里云sdk
pip install aliyun-python-sdk-core
pip install aliyun-python-sdk-core-v3  #新版,支持python3.x的
'''
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest
client = AcsClient('LTAIEx3Gbdbceg2C', 'MsCoWUm3x2iXaIcvtqhQLi9yj6nHxX', 'cn-hangzhou')


request = CommonRequest()
request.set_accept_format('json')
request.set_domain('dysmsapi.aliyuncs.com')
request.set_method('POST')
request.set_protocol_type('https') # https | http
request.set_version('2017-05-25')
request.set_action_name('SendSms')

request.add_query_param('RegionId', "cn-hangzhou")
request.add_query_param('PhoneNumbers', "13994729402")
request.add_query_param('SignName', "北网实训组")
request.add_query_param('TemplateCode', "SMS_165745016")
request.add_query_param('TemplateParam', "{\"code\":\"765432\"}")

response = client.do_action(request)
# python2:  print(response)
print(str(response, encoding = 'utf-8'))